| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var assert = require('chai').assert, |
||
| 64 | it('Build', function(){ |
||
| 65 | var display = GedcomX.DisplayProperties() |
||
| 66 | .setName('Joe') |
||
| 67 | .setGender('Male') |
||
| 68 | .setLifespan('1900-1956') |
||
| 69 | .setBirthDate('3 March 1900') |
||
| 70 | .setBirthPlace('A place') |
||
| 71 | .setDeathDate('14 January 1956') |
||
| 72 | .setDeathPlace('Another place') |
||
| 73 | .setMarriageDate('9 August 1927') |
||
| 74 | .setMarriagePlace('Marriage place') |
||
| 75 | .setAscendancyNumber('3') |
||
| 76 | .setDescendancyNumber('6') |
||
| 77 | .addFamilyAsParent({ |
||
| 78 | "parent1" : { |
||
| 79 | "resource" : "#parent1" |
||
| 80 | }, |
||
| 81 | "parent2" : { |
||
| 82 | "resource" : "#parent2" |
||
| 83 | }, |
||
| 84 | "children" : [ |
||
| 85 | { "resource" : "#child1" }, |
||
| 86 | { "resource" : "#child2" } |
||
| 87 | ] |
||
| 88 | }) |
||
| 89 | .addFamilyAsChild({ |
||
| 90 | "parent1" : { |
||
| 91 | "resource" : "#parent1" |
||
| 92 | }, |
||
| 93 | "parent2" : { |
||
| 94 | "resource" : "#parent2" |
||
| 95 | }, |
||
| 96 | "children" : [ |
||
| 97 | { "resource" : "#child1" }, |
||
| 98 | { "resource" : "#child2" } |
||
| 99 | ] |
||
| 100 | }); |
||
| 101 | assert.equal(display.getName(), 'Joe'); |
||
| 102 | assert.equal(display.getGender(), 'Male'); |
||
| 103 | assert.equal(display.getLifespan(), '1900-1956'); |
||
| 104 | assert.equal(display.getBirthDate(), '3 March 1900'); |
||
| 105 | assert.equal(display.getBirthPlace(), 'A place'); |
||
| 106 | assert.equal(display.getDeathDate(), '14 January 1956'); |
||
| 107 | assert.equal(display.getDeathPlace(), 'Another place'); |
||
| 108 | assert.equal(display.getMarriageDate(), '9 August 1927'); |
||
| 109 | assert.equal(display.getMarriagePlace(), 'Marriage place'); |
||
| 110 | assert.equal(display.getAscendancyNumber(), '3'); |
||
| 111 | assert.equal(display.getDescendancyNumber(), '6'); |
||
| 112 | assert.equal(display.getFamiliesAsParent().length, 1); |
||
| 113 | assert.equal(display.getFamiliesAsChild().length, 1); |
||
| 114 | }); |
||
| 115 | |||
| 163 | }); |